import cMenu from './contextMenu'
import store from '@/store'
import editorware from '../../utils/editorMiddleware'
import { MessageBox } from 'element-ui'
const contextMenu = {
    jsdialogVisible: false,
    formData: {
        dot: [
            // { type: 'text', label: '绘标风格'},
            { type: 'slot', label: '绘标样式：', prop: 'image', span: 24 },
            { type: 'input', label: '绘标缩放：', value: '', prop: 'type', span: 12 },
            { type: 'input', label: '透明度：', value: '', prop: 'opacity', span: 12 },
            // { type: 'text', label: '字体风格'},
            { type: 'input', label: '字体大小：', prop: 'lineWidth', span: 12 },
            { type: 'select', label: '字体样式：', prop: 'font_family', span: 12 },
            { type: 'color', label: '字体颜色：', prop: 'color', span: 12 }
        ],
        line: [
            { type: 'color', label: '线的颜色：', value: '', prop: 'color', span: 12 },
            { type: 'input', label: '透明度：', value: '', prop: 'opacity', span: 12 },
            { type: 'input', label: '线宽：', value: '', prop: 'width', span: 12 },
            { type: 'select', label: '线的样式：', value: '', prop: 'type', span: 12 }
        ],
        cover: [
            { type: 'radio', label: '是否填充：', value: '', prop: 'opacity', span: 12 },
            { type: 'color', label: '填充颜色：', value: '', prop: 'name', span: 12 },

            { type: 'radio', label: '是否边框：', value: '', prop: 'opacity', span: 12 },
            { type: 'input', label: '边框透明度：', value: '', prop: 'name', span: 12 },
            { type: 'color', label: '边框颜色：', value: '', prop: 'name', span: 12 },
            { type: 'input', label: '透明度：', value: '', prop: 'opacity', span: 12 },
            { type: 'input', label: '线宽：', value: '', prop: 'opacity', span: 12 },

            { type: 'select', label: '线的样式：', value: '', prop: 'opacity', span: 12 }
        ]
    },
    layerMenu: {
        model3D: [
            {
                name: '图层属性',
                id: 20,
                icon: 'el-icon-s-grid',
                click: () => {
                    closeContextMenu()
                    cMenu.property()
                }
            },
            {
                name: '删除图层',
                id: 21,
                icon: 'el-icon-delete',
                click: () => {
                    closeContextMenu()
                    cMenu.removeGraphic()
                }
            },
            {
                name: '上移图层',
                id: 22,
                icon: 'el-icon-sort-up',
                click: () => {}
            },
            {
                name: '下移图层',
                id: 23,
                icon: 'el-icon-sort-down',
                click: () => {}
            }
        ],
        layer: [
            {
                name: '属性',
                id: 1,
                icon: 'el-icon-s-grid',
                click: () => {
                    // editorware.isFlyTo = true
                    closeContextMenu()
                    cMenu.property()
                }
            },
            {
                name: '',
                id: 2,
                separate: true,
                icon: '',
                click: () => {}
            },
            {
                name: '移动(偏移)',
                id: 5,
                icon: 'el-icon-rank',
                click: () => {
                    if (editorware.treeSelectNode.data.type == 'tile') {
                        // 瓦片偏移
                        closeContextMenu()
                        // MessageBox.alert('功能正在开发中', '', {
                        //     confirmButtonText: '确定',
                        //     callback: action => {
                        //         editorware.rightClickData = ''
                        //     }
                        // })
                        cMenu.tileAdjustment()
                    } else {
                        // tif偏移
                        closeContextMenu()
                        cMenu.skewingAmend()
                    }
                }
            },
            {
                name: '剪切',
                id: 3,
                icon: 'el-icon-scissors',
                click: () => {
                    closeContextMenu()
                    cMenu.copyShearGraphic('shear')
                }
            },
            {
                name: '复制',
                id: 4,
                icon: 'el-icon-copy-document',
                click: () => {
                    closeContextMenu()
                    cMenu.copyShearGraphic('copy')
                }
            },
            // {
            //     name: '粘贴',
            //     id: 5,
            //     icon: 'el-icon-document-copy',
            //     click: () => {
            //         closeContextMenu()
            //         // cMenu.pasteGraphic()
            //         cMenu.pasteFolder()
            //     }
            // },
            {
                name: '删除',
                id: 6,
                icon: 'el-icon-delete',
                click: () => {
                    closeContextMenu()
                    cMenu.removeGraphic()
                }
            }
        ]
    },
    treeMenu: {
        model3D: [
            {
                name: '添加图层',
                id: 7,
                icon: 'el-icon-document-add',
                click: () => {}
            }
        ],
        folder: [
            {
                name: '剪切',
                id: 8,
                icon: 'el-icon-scissors',
                click: () => {
                    closeContextMenu()
                    cMenu.copyShearFolder('shear')
                }
            },
            {
                name: '复制',
                id: 9,
                icon: 'el-icon-copy-document',
                click: () => {
                    closeContextMenu()
                    cMenu.copyShearFolder('copy')
                }
            },
            {
                name: '粘贴',
                id: 10,
                icon: 'el-icon-document-copy',
                click: () => {
                    closeContextMenu()
                    cMenu.pasteFolder()
                }
            },
            {
                name: '另存为',
                id: 11,
                icon: 'el-icon-document-copy',
                click: () => {
                    closeContextMenu()
                    cMenu.exportFolderJson()
                }
            },
            {
                name: '',
                id: 12,
                separate: true,
                icon: '',
                click: () => {}
            },
            {
                name: '重命名',
                id: 13,
                icon: 'el-icon-edit-outline',
                click: () => {
                    closeContextMenu()
                    mVm.$prompt('请输入文件夹名称', '重命名', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        cancelButtonClass: 'el-button--primary',
                        customClass: 'inputFolder'
                    }).then(({ value }) => {
                        if (value) {
                            cMenu.rechristen(value)
                        } else {
                            mVm.$alert('文件夹名称不能为空')
                        }
                    })
                }
            },
            {
                name: '批量风格',
                id: 14,
                icon: 'el-icon-files',
                click: () => {
                    closeContextMenu()
                    showDialog()
                }
            },
            {
                name: '删除内容',
                id: 15,
                icon: 'el-icon-document-delete',
                click: () => {
                    closeContextMenu()
                    cMenu.removeContent()
                }
            },
            {
                name: '锁定',
                id: 16,
                icon: 'el-icon-lock',
                click: () => {
                    closeContextMenu()
                    cMenu.lockFolder()
                }
            },
            {
                name: '',
                id: 17,
                separate: true,
                icon: '',
                click: () => {}
            },
            {
                name: '添加文件夹',
                id: 18,
                icon: 'el-icon-folder-add',
                click: () => {
                    closeContextMenu()
                    mVm.$prompt('请输入文件夹名称', '添加文件夹', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        cancelButtonClass: 'el-button--primary',
                        customClass: 'inputFolder'
                    }).then(({ value }) => {
                        if (value) {
                            cMenu.addFolder(value)
                        } else {
                            mVm.$alert('文件夹名称不能为空')
                        }
                    })
                }
            },
            {
                name: '删除文件夹',
                id: 19,
                icon: 'el-icon-folder-remove',
                click: () => {
                    closeContextMenu()
                    mVm.$confirm('此操作将永久删除该文件夹, 是否继续?', '删除文件夹', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        cancelButtonClass: 'el-button--primary',
                        customClass: 'inputFolder',
                        type: 'warning'
                    }).then(() => {
                        cMenu.removeFolder()
                    })
                }
            }
        ],
        unlock: [
            {
                name: '解除锁定',
                id: 24,
                icon: 'el-icon-unlock',
                click: () => {
                    closeContextMenu()
                    cMenu.unlockFolder()
                }
            }
        ]
    }
}
function closeContextMenu() {
    store.commit('setContextMenu', { isShow: false })
}
function showDialog() {
    store.commit('showDialog', { isShow: true })
}
export default contextMenu
